package cn.xej.vue.controller;

import cn.xej.vue.common.RespObj;
import cn.xej.vue.pojo.User;
import cn.xej.vue.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/findAll")
    public RespObj findAll(Integer page,Integer rows){
        return userService.findAll();
    }

    @PostMapping("/addUser")
    public RespObj addUser(@RequestBody  User user){
        return userService.addUser(user);
    }

    @GetMapping("/delUser")
    public RespObj delUser(String id){
        return userService.delUser(id);
    }

    @GetMapping("/findUserById")
    public RespObj findUserById(String id){
        return userService.findUserById(id);
    }

    @PostMapping("/updateUser")
    public RespObj updateUser(@RequestBody User user){
        return userService.updateUser(user);
    }
}
